from utils.logger import logger
from model.models import PointsPayment

def render_transaction(transaction):
    payment_info = transaction.payment_method.pay(transaction.amount)
    message = f"{transaction.user} 在 {transaction.page.name} 购买了 {transaction.item}，{payment_info}。"
    print(message)
    logger.info(message)

    # 高积分预警
    if isinstance(transaction.payment_method, PointsPayment) and transaction.amount > 200:
        warning = "疑似潜在脱坑客户"
        print(warning)
        logger.warning(warning)

    return message
